#include <iostream>
#include <string>

class Widget {
public:
    virtual void draw() {
        std::cout << "Drawing Widget" << std::endl;
    }
};

class Button : public Widget {
public:
    void draw() override {
        std::cout << "Drawing Button" << std::endl;
    }
};

class TextBox : public Widget {
private:
    std::string text;

public:
    TextBox(const std::string& txt) : text(txt) {}

    void draw() override {
        if (!text.empty()) {
            std::cout << "Drawing TextBox: " << text << std::endl;
        } else {
            // 不绘制任何东西，违反了Widget的预期行为
        }
    }
};

void renderScreen(Widget* widget) {
    widget->draw();
}

int main() {
    Widget* w = new Widget();
    Widget* b = new Button();
    Widget* t = new TextBox("Hello");

    renderScreen(w); // Draws "Drawing Widget"
    renderScreen(b); // Draws "Drawing Button"
    renderScreen(t); // Draws "Drawing TextBox: Hello"

    delete w;
    delete b;
    delete t;
    return 0;
}